import { TargetState } from "framework/FSM/DecisionTree/DecisionTargetState";
import { ITransition } from ".";

import { DecisionNode } from "..";
import { ActionLog } from "../../../../test/my_unit/HFSM/Actions/Index";
import { State } from "../AState";
import { Condition } from "../Condition/Condition";
import { BinaryDecision } from "../DecisionTree/Decision";
import { DecisionTreeNode } from "../DecisionTree/DecisionTreeNode";

export class Transition<T extends ICondition=ICondition , U extends IStateArg = IStateArg> implements ITransition<U>
{
    private level:number=0;
    private origin!:State;
    constructor(origin:State,target:State, condition:T)
    {
        this.targetState = target;
        this.condition = condition;
        origin.addTransition(this);
        this.level = origin.getLevel() - target.getLevel();

        this.actions =  [];
    }
    setOrigin(origin: State): void 
    {
        this.origin  = origin;
    }
    private actions!:Action[];

    private targetState!:State;

    private condition!:T;

    public getActions():Action[]
    {
        return this.actions;
    }

    public getTargetState():State|undefined
    {
        return this.targetState;

    }
    public isTriggered(arg:U):boolean
    {
        return this.condition.test(arg);
    }

    public getLevel():number
    {
        return this.level ;
    }

    public setCondition(condition:T)
    {
        this.condition = condition;
    }

    
}


